<template>
  <div class="bottom-tab">
    <BottomTabItem
      v-for="item in value"
      :tab="item"
      :width="`${100 / value.length}%`"
      :key="item.tabName"
      @click.native="selectItem(item.tabName)"
    />
  </div>
</template>

<script setup lang="ts">
import { Tab } from '@/types/home.d';
import BottomTabItem from '@/components/bottom/BottomTabItem.vue';
interface Props {
  value: Tab[];
}

const props = withDefaults(defineProps<Props>(), {
  value: () => []
});

interface Emits {
  (e: 'input', params: Tab[]): void;
}
const emits = defineEmits<Emits>();

const selectItem = (tabName: string) => {
  const tabsResult = props.value.map(item => ({
    ...item,
    active: item.tabName === tabName
  }));
  emits('input', tabsResult);
};
</script>

<style lang="less">
.bottom-tab {
  width: 100vw;
  display: flex;
  justify-content: space-between;
}
</style>
